<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>售后管理 - 添加售后订单 | 电动车销售系统</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/aftersalesadmin/addaftersale.css">
</head>
<body>
<header class="dashboard-header">
    <div class="container">
        <div class="d-flex justify-content-between align-items-center">
            <div>
                <h1 class="h3 mb-0"><i class="bi bi-bicycle"></i> 电动车销售管理系统</h1>
                <p class="mb-0 opacity-75">售后管理 - 添加新售后订单</p>
            </div>
            <div class="d-flex align-items-center">
                <div class="me-3">
                    <span class="d-none d-md-inline">${currentUser.name}</span>
                    <div class="badge bg-light text-dark">
                        <i class="bi bi-person-circle me-1"></i> 售后管理员
                    </div>
                </div>
                <div class="dropdown">
                    <button class="btn btn-light rounded-circle p-1" type="button" data-bs-toggle="dropdown">
                        <i class="bi bi-gear fs-5"></i>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-end">
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/change_password.jsp"><i class="bi bi-lock me-2"></i> 修改密码</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item text-danger" href="${pageContext.request.contextPath}/LogoutServlet"><i class="bi bi-box-arrow-right me-2"></i> 退出登录</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</header>

<div class="container mb-5">
    <div class="row justify-content-center">
        <div class="col-lg-9">
            <div class="dashboard-card shadow">
                <div class="card-header">
                    <div>
                        <h5 class="card-title"><i class="bi bi-tools me-2 text-primary"></i>添加新售后订单</h5>
                        <p class="card-subtitle">填写售后订单信息并提交</p>
                    </div>
                </div>

                <div class="card-body">
                    <div class="info-box">
                        <p><i class="bi bi-info-circle"></i> 请确保填写所有必填字段（标记为 * 的字段）</p>
                        <p><i class="bi bi-info-circle"></i> 售后订单创建后需要及时处理客户问题</p>
                    </div>

                    <form action="afterSalesAdmin?action=add" method="post" class="needs-validation" novalidate>
                        <div class="form-section">
                            <div class="d-flex align-items-center mb-3">
                                <div class="section-icon">
                                    <i class="bi bi-cart"></i>
                                </div>
                                <h5 class="form-section-title m-0">订单信息</h5>
                            </div>

                            <div class="row">
                                <div class="col-md-6 form-group">
                                    <label for="saleOrderId" class="form-label required-label">关联销售订单ID</label>
                                    <input type="number" class="form-control form-control-lg"
                                           id="saleOrderId" name="saleOrderId" required>
                                    <div class="invalid-feedback">
                                        请输入关联销售订单ID
                                    </div>
                                </div>
                                <div class="col-md-6 form-group">
                                    <label for="userId" class="form-label required-label">处理用户ID</label>
                                    <input type="number" class="form-control form-control-lg"
                                           id="userId" name="userId" required>
                                    <div class="invalid-feedback">
                                        请输入处理用户ID
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="form-section">
                            <div class="d-flex align-items-center mb-3">
                                <div class="section-icon">
                                    <i class="bi bi-clipboard"></i>
                                </div>
                                <h5 class="form-section-title m-0">问题详情</h5>
                            </div>

                            <div class="form-group">
                                <label for="problem" class="form-label required-label">问题描述</label>
                                <textarea class="form-control form-textarea"
                                          id="problem" name="problem" rows="4" required></textarea>
                                <div class="invalid-feedback">
                                    请输入问题描述
                                </div>
                            </div>
                        </div>

                        <div class="form-section">
                            <div class="d-flex align-items-center mb-3">
                                <div class="section-icon">
                                    <i class="bi bi-gear"></i>
                                </div>
                                <h5 class="form-section-title m-0">状态信息</h5>
                            </div>

                            <div class="row">
                                <div class="col-md-6 form-group">
                                    <label for="status" class="form-label required-label">订单状态</label>
                                    <select class="form-select form-select-lg" id="status" name="status" required>
                                        <option value="0">未处理</option>
                                        <option value="1">处理中</option>
                                        <option value="2">已解决</option>
                                    </select>
                                    <div class="invalid-feedback">
                                        请选择订单状态
                                    </div>
                                </div>
                                <div class="col-md-6 form-group">
                                    <label for="createTime" class="form-label required-label">创建时间</label>
                                    <input type="datetime-local" class="form-control form-control-lg"
                                           id="createTime" name="createTime" required>
                                    <div class="invalid-feedback">
                                        请选择创建时间
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="action-buttons">
                            <button type="submit" class="btn btn-submit">
                                <i class="bi bi-check-circle me-1"></i> 提交订单
                            </button>
                            <a href="afterSalesAdmin?action=list" class="btn btn-cancel">
                                <i class="bi bi-x-circle me-1"></i> 取消返回
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
    // 表单验证
    (function () {
        'use strict'

        var forms = document.querySelectorAll('.needs-validation')

        Array.prototype.slice.call(forms)
            .forEach(function (form) {
                form.addEventListener('submit', function (event) {
                    if (!form.checkValidity()) {
                        event.preventDefault()
                        event.stopPropagation()
                    }

                    form.classList.add('was-validated')
                }, false)
            })
    })()

    // 设置默认时间为当前时间
    document.addEventListener('DOMContentLoaded', function() {
        const now = new Date();
        const localDateTime = new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(0, 16);
        document.getElementById('createTime').value = localDateTime;
    });
</script>
</body>
</html>